package com.xzlcPT.controller;/**
 * Created by Administrator on 2017/8/9.
 */

import com.xzlcPT.bean.XzLogin;
import com.xzlcPT.bean.XzResumeCollect;
import com.xzlcPT.service.XzResumeCollectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import java.util.*;

/**
 * @author 甘汝雷
 * @create 2017-08-09 17:18
 **/
@Controller
@RequestMapping("/ResumeCollect")
@SessionAttributes({"userLogin"})
public class ResumeCollectController extends BaseController{

    @Autowired
    private XzResumeCollectService resumeCollectService;

    @RequestMapping("insertSelective.do")
    public ModelAndView insertSelective(@ModelAttribute("userLogin") XzLogin xzLogin, Long resumeId, RedirectAttributes rattr) {
        ModelAndView mv=new ModelAndView("redirect:/view/foreEnd3/zpc_resume_manage.html");
        XzResumeCollect xzResumeCollect=new XzResumeCollect();
        Date date=new Date();
        xzResumeCollect.setCompanyId(xzLogin.getCompany().getCompanyId());
        xzResumeCollect.setResumeId(resumeId);
        xzResumeCollect.setCollectTime(date);
        int i = resumeCollectService.insertSelective(xzResumeCollect);
        rattr.addAttribute("type","wdsc");
        return mv;
    }
    @ResponseBody
    @RequestMapping("deleteByPrimaryKey.do")
    public Map deleteByPrimaryKey(Long collectId){
        int i=resumeCollectService.deleteByPrimaryKey(collectId);
        Map map=new HashMap();
        if(i==1){
            map.put("msg","ok");
        }else {
            map.put("msg","ok");
        }
        return map;
    }
    @ResponseBody
    @RequestMapping("delAllChoose.do")
    public Map delAllChoose(@RequestBody Long[] collect_ids){
        Map map=new HashMap();
        List<Long> list=new ArrayList<>();
        for (Long collectId:collect_ids){
            list.add(collectId);
        }
        int i=resumeCollectService.delAllChoose(list);
        if (i==1){
            map.put("msg","ok");
        }else {
            map.put("msg","err");
        }
        return map;
    }
}
